//
//  DetailesViewControl.m
//  YaoHeAPP
//
//  Created by mac on 15/12/17.
//  Copyright © 2015年 mac. All rights reserved.
//
//****************************************** 详情页面

#import "DetailesViewControl.h"
#import "Controller.h"
#import "Masonry.h"
#import "DetailesClass.h"
#import "DatabaseTool.h"
#import "TextTableViewCell.h"
#import "BtnTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "AccurateVC.h"
#import "CancelReason.h"
#import "SVProgressHUD.h"
#import "Define.h"
#import "pushDatamodel.h"
#import "XiaDan.h"
#import "OrderDetailesVC.h"
#import "CWStarRateView.h"
#import "ProvinceAndCity.h"
#import "UIImageView+WebCache.h"
#import "DXdjsView.h"

#import "BigimageView.h"
#import "SVPullToRefresh.h"

#import "UIView+HY.h"
#import "UILabel+StringFrame.h"

#define Color153  [UIColor colorWithRed:80.f/255.f green:80.f/255.f blue:80.f/255.f alpha:1]

@interface DetailesViewControl ()<DXdjsDelegate>
{
    NSInteger width;
    NSInteger height;
    DetailesClass*detailMessage;//详情类
    UIImageView*ststusImage;//显示状态图片
    UILabel*statusLabel;//第0分区区头标题
    
    UILabel*titleLabel;//导航条标题
    NSArray*arrayT;
    TextTableViewCell*cell2;//没有锁货下单的按钮
    BtnTableViewCell*btnCell;//有锁货下单的按钮
    BOOL juan_cai;//卷材
    BOOL ban__cai;//板材
    BOOL guan_cai;//管材
    BOOL xing_cai;//型材
    BOOL lv_cai;  //铝材
    
    UILabel*hourLabel,*minuteLabel,*secondsLabel;
    UIImageView*djsBgImg;
    
    UIView*backDjs;//放倒计时
    UIImageView*imageIs;
    
    NSInteger cellH;
    NSInteger beizhuH;
    NSInteger beizhuW;
    
}
@property(nonatomic,strong) DXdjs*djs;
//@property (assign , nonatomic) int day;
@property (assign , nonatomic) int hour;
@property (assign , nonatomic) int minute;
@property (assign , nonatomic) int second;

@end

@implementation DetailesViewControl

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"DetailesViewControl"];
    
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"DetailesViewControl"];
    
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];

    
    [[NSNotificationCenter defaultCenter]  addObserver:self selector:@selector(upview:) name:@"upview" object:nil];
}

-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"SHOPCAR_SHOW_NOW"];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"upview" object:nil];
    dispatch_source_cancel(self.djs.timer);
}

-(void)djsOngoing:(NSArray *)djsArr
{
    hourLabel.text=[NSString stringWithFormat:@"%@ : %@ : %@",djsArr[1],djsArr[2],djsArr[3]];
}

-(void)djsEnd:(NSArray *)djsArr
{
    
    if (detailMessage.status==10){
       
        hourLabel.text = @"00";
        minuteLabel.text = @"00";
        secondsLabel.text = @"00";
        dispatch_source_cancel(self.djs.timer);
        [detailMessage setValue:@"20" forKey:@"status"];
        
    }

    
   
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    NSDictionary*dic=@{@"purchase_id":self.purchaseID};
    
    self.view.backgroundColor=bgVCcolor;
    //加一个导航条
    UIView*navcBar=[[UIView alloc]init];
    navcBar.backgroundColor=[UIColor colorWithRed:90.f/255.f green:191.f/255.f blue:219.f/255.f alpha:1];
    [self.view addSubview:navcBar];
    [self.view bringSubviewToFront:navcBar];
    [navcBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);   make.left.offset(0);
        make.height.offset(60);  make.right.offset(0);
    }];

    //返回按钮
    UIButton*leftButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setBackgroundImage:[UIImage imageNamed:@"return"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [navcBar addSubview:leftButton];
    [leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(6);
        make.width.offset(24);
        make.height.offset(22);
        make.bottom.offset(-12);
    }];
    
    //调出详情页数据
    [Controller requestWithURL:@"AppPurchaseInfo/PostQueryPurchaseDetail?from=app" jsondic:dic finishBlock:^(ClassData *classData) {
        if ([classData.number integerValue]==0) {

        detailMessage=[[DetailesClass alloc]initWithDic:classData.data];
        
        backDjs=[[UIView alloc]init];
        backDjs.frame=CGRectMake(width-140, 0, 140, 20);
        djsBgImg=[[UIImageView alloc]init];
        djsBgImg.image=[UIImage imageNamed:@"countdown"];
        djsBgImg.frame=CGRectMake(50, 2, 90, 20);
        [backDjs addSubview:djsBgImg];
        
        
        UILabel*jieshu=[[UILabel alloc]init];
        jieshu.text=@"距结束:";
        jieshu.font=font14;
        jieshu.frame=CGRectMake(0, 2, 50, 20);
        jieshu.textAlignment=NSTextAlignmentCenter;
        [backDjs addSubview:jieshu];
        hourLabel=[[UILabel alloc]init];
        hourLabel.frame=CGRectMake(50, 2, 90, 18);
        hourLabel.textAlignment=NSTextAlignmentCenter;
        hourLabel.font=font14;
        hourLabel.textColor=[UIColor colorWithRed:54.f/255.f green:177.f/255.f blue:248.f/255.f alpha:1];
        [backDjs addSubview:hourLabel];
        
    
        self.djs = [DXdjs dlsWithCountdownTime:detailMessage.total_seconds];
        self.djs.delegate = self;
        
        juan_cai =[[NSString stringWithFormat:@"%@",detailMessage.category_name] isEqualToString:@"卷材"];
        ban__cai =[[NSString stringWithFormat:@"%@",detailMessage.category_name] isEqualToString:@"板材"];
        guan_cai =[[NSString stringWithFormat:@"%@",detailMessage.category_name] isEqualToString:@"管材"];
        xing_cai =[[NSString stringWithFormat:@"%@",detailMessage.category_name] isEqualToString:@"型材"];
//        lv_cai=[[NSString stringWithFormat:@"%@",detailMessage.category_name] containsString:@"铝材"];
        lv_cai=[[NSString stringWithFormat:@"%@",detailMessage.category_name] rangeOfString:@"铝材"].location != NSNotFound;
           
        //要显示的内容
        NSString*varietyName=detailMessage.variety_name;//品名
            NSString*material=detailMessage.material_name;//材质
        if (lv_cai==YES) {
            material=detailMessage.tradeMark;
        }
        NSString*supface=detailMessage.supface_name;//表面
        if(supface.length==0){
            supface=@"无";
        }
        NSString*materialSupface=[NSString stringWithFormat:@"%@/%@",material,supface];//材质和表面
            
        NSString*speccode=[NSString stringWithFormat:@"%@",detailMessage.spec_code];//规格
        NSString*tolerance=[NSString stringWithFormat:@"%@",detailMessage.tolerance];//公差
        if (lv_cai==YES) {
            tolerance=[NSString stringWithFormat:@"%@",detailMessage.nationalStandard];
        }
        NSString*weight=@"";
        NSString*quantity=@"";
        if (detailMessage.weight.length==0){
            weight=@"无";
        }
        if (detailMessage.weight.length>0) {
            weight=[NSString stringWithFormat:@"%@吨",detailMessage.weight];
        }
        if (detailMessage.quantity.length==0){
            quantity=@"无";
        }else {
            if (xing_cai==YES||juan_cai==YES){
                quantity=[NSString stringWithFormat:@"%@个",detailMessage.quantity];
            }
            if (ban__cai==YES||lv_cai==YES){
                quantity=[NSString stringWithFormat:@"%@张",detailMessage.quantity];
            }
            if (guan_cai==YES) {
                quantity=[NSString stringWithFormat:@"%@支",detailMessage.quantity];
            }
        }
        NSString*weightQuantity=[NSString stringWithFormat:@"%@/%@",weight,quantity];//重量，数量
        
        NSString*manufacturer=detailMessage.manufacturer_name;
        if (manufacturer.length==0) {
            manufacturer=@"无";
        }
        NSString*shengCityManufacturer=[NSString stringWithFormat:@"%@%@/%@",[ProvinceAndCity inputShengID:detailMessage.supply_provinceID],[ProvinceAndCity inputCityID: detailMessage.supply_cityID],manufacturer];//省市、生产商
        
        NSInteger isInvoice=[detailMessage.is_nned_invoice integerValue];//将string转为integer类型
        NSString*is_nned_invoice=[NSString string];//是否需要发票
        if (isInvoice==0)
        {
            is_nned_invoice=@"不需要";
        }
        if (isInvoice==1)
        {
            is_nned_invoice=@"需要";
        }
        NSString*remark=[NSString stringWithFormat:@"%@",detailMessage.remark];//备注信息
        //在数组中添加
        _detailArray=[[NSMutableArray alloc]initWithObjects:@"",varietyName,materialSupface,speccode,tolerance,weightQuantity,shengCityManufacturer,is_nned_invoice,remark,@"",nil];
        
        //导航条标题
        titleLabel=[[UILabel alloc]init];
        titleLabel.textAlignment=NSTextAlignmentCenter;
        titleLabel.font=Font(17);
        titleLabel.textColor=[UIColor whiteColor];
        [navcBar addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(25);
            make.left.offset(width/2-100);
            make.width.offset(200);
            make.height.offset(30);
        }];
        baojiaArray=[[NSMutableArray alloc]init];
        NSMutableArray*baoJAry=[[NSMutableArray alloc]initWithArray:detailMessage.quoteinfonsAry];
        for (NSInteger i=0; i<baoJAry.count; i++)
        {
            NSDictionary*dic=baoJAry[i];
            Quoteinfons*quote=[[Quoteinfons alloc]initWithDic:dic];
            [baojiaArray addObject:quote];
        }
        
        //创建表格
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 60, width, height-120) style:UITableViewStylePlain];
        _tableView.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        [self.view addSubview:_tableView];
        
            if (lv_cai==YES) {
                arrayT=@[
                         @"求  购  详  情:",
                         @"品           名:",
                         @"牌 号/表 面:",
                         @"规           格:",
                         @"国           标:",
                         @"重 量/数 量:",
                         @"交割地/钢厂:",
                         @"发           票:",
                         @"备           注:",
                         @""
                         ];
            }
            else{
                arrayT=@[
                         @"求  购  详  情:",
                         @"品           名:",
                         @"材 质/表 面:",
                         @"规           格:",
                         @"公 差 范 围:",
                         @"重 量/数 量:",
                         @"交割地/钢厂:",
                         @"发           票:",
                         @"备           注:",
                         @""
                         ];
            }

            
        //注册单元格
        [_tableView registerClass:[TextTableViewCell class] forCellReuseIdentifier:@"textCell"];
        //[_tableView registerNib:[UINib nibWithNibName:@"TextTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"textCell"];
        //带有锁货下单按钮的单元格
        [_tableView registerClass:[BtnTableViewCell class] forCellReuseIdentifier:@"btnCell"];
        
        UIView*backView=[[UIView alloc]init];
        backView.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [self.view addSubview:backView];
        [backView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(0);
            make.right.offset(0);
            make.bottom.offset(0);
            make.height.offset(60);
        }];
        
        //电话找货按钮
        UIButton*phoneBtnz=[UIButton buttonWithType:UIButtonTypeCustom];
        phoneBtnz.layer.masksToBounds=YES;
        phoneBtnz.layer.cornerRadius=18;
        [phoneBtnz setBackgroundImage:[UIImage imageNamed:@"Phone_call_for_goods"] forState:UIControlStateNormal];
        [phoneBtnz setBackgroundImage:[UIImage imageNamed:@"phoneFindHF"] forState:UIControlStateHighlighted];
        [phoneBtnz addTarget:self action:@selector(callPhone) forControlEvents:UIControlEventTouchUpInside];
        [backView addSubview:phoneBtnz];
        [phoneBtnz mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(20);
            make.height.offset(36);
            make.width.offset(36);
            make.bottom.offset(-12);
        }];
        
        if (detailMessage.status==10||detailMessage.status==20)
        {
            //取消发布按钮
            UIButton* quxiao_Btn=[UIButton buttonWithType:UIButtonTypeCustom];
            quxiao_Btn.layer.masksToBounds=YES;
            quxiao_Btn.layer.cornerRadius=18;
            quxiao_Btn.backgroundColor=[UIColor colorWithRed:196.f/255.f green:196.f/255.f blue:196.f/255.f alpha:1];
            [quxiao_Btn addTarget:self action:@selector(quxiao_Btn) forControlEvents:UIControlEventTouchUpInside];
            [quxiao_Btn setTitle:@"取消求购" forState:UIControlStateNormal];
            [quxiao_Btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [backView addSubview:quxiao_Btn];
            [quxiao_Btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(phoneBtnz.mas_right).offset(10);
                make.right.offset(-20);
                make.height.offset(36);
                make.bottom.offset(-12);
            }];
        }
        else
        {
            //重新采购
            UIButton* again_Btn=[UIButton buttonWithType:UIButtonTypeCustom];
            again_Btn.layer.masksToBounds=YES;
            again_Btn.layer.cornerRadius=20;
            again_Btn.backgroundColor=[UIColor colorWithRed:55.f/255.f green:177.f/255.f blue:249.f/255.f alpha:1];
            [again_Btn addTarget:self action:@selector(again_Btn) forControlEvents:UIControlEventTouchUpInside];
            [again_Btn setTitle:@"重新采购" forState:UIControlStateNormal];
            [again_Btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [backView addSubview:again_Btn];
            [again_Btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(phoneBtnz.mas_right).offset(10);
                make.right.offset(-20);
                make.height.offset(36);
                make.bottom.offset(-12);
            }];
        }
      }
        else{ ALERTSHOW(classData.message) }
        
        __block DetailesViewControl *vc = self;
        [_tableView addPullToRefreshWithActionHandler:^{
            //刷新数据的操作
            [vc viewDidLoad];
        }];

        
    }];
    
}
//返回单元格的分区个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
//返回单元格的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0)
    {
        if (detailMessage.img_pathsAry.count>0) {
            return 10;
        }
        return 9;
        
    }
    if (baojiaArray.count==0)
    {
        return 1;
    }
       return baojiaArray.count;
    
}
//返回每个单元格要显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //没有下方的报价
    if (indexPath.section==0)
    {
        UITableViewCell*cell=[[UITableViewCell alloc]init];
        _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        //第0行
        UILabel*nameLabel=[[UILabel alloc]init];
        nameLabel.font=font15;
        [cell addSubview:nameLabel];
        if (indexPath.row==0)
        {
            //求购详情label
            nameLabel.frame=CGRectMake(20, 5, 150, 25);
            nameLabel.text=arrayT[indexPath.row];
            //显示时间
            UILabel*creatTime=[[UILabel alloc]init];
            creatTime.text=detailMessage.create_time;
            creatTime.font=font13;
            creatTime.textColor=Color153;
            creatTime.frame=CGRectMake(width-135, 5, 135, 25);
            [cell addSubview:creatTime];
            //时钟图片
            UIImageView*imageTm=[[UIImageView alloc]init];
            imageTm.image=[UIImage imageNamed:@"ic_qiugou_time"];
            imageTm.frame=CGRectMake(width-155, 7.5, 20, 20);
            [cell addSubview:imageTm];
        }
        //其他行
        //商品详情
        else
        {
            nameLabel.text=arrayT[indexPath.row];
            nameLabel.font=font15;
            nameLabel.frame=CGRectMake(20, 12.5, 100, 16);
            nameLabel.textColor=Color153;
            //显示详细信息
            UILabel*messageL=[[UILabel alloc]initWithFrame:CGRectMake(120, 12.5, width-125, 16)];
            messageL.text=_detailArray[indexPath.row];
            messageL.textColor=Color153;
            messageL.font=font15;
            messageL.numberOfLines=0;
            if (indexPath.row==6) {
                messageL.frame=CGRectMake(120, 12.5, width-125, [_detailArray[indexPath.row] boundingRectWithSize: CGSizeMake(messageL.frame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:messageL.font ,NSFontAttributeName, nil] context:nil].size.height);
            }
            if (indexPath.row==8) {
                //计算文字高度
                messageL.frame=CGRectMake(120, 12.5, width-125, [_detailArray[indexPath.row] boundingRectWithSize: CGSizeMake(messageL.frame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:messageL.font ,NSFontAttributeName, nil] context:nil].size.height);
                
            }
            if (indexPath.row==9) {
                for (NSInteger i=0; i<detailMessage.img_pathsAry.count; i++) {
                    imageIs=[[UIImageView alloc]initWithFrame:CGRectMake(2.5+i*(width/5-2.5), 2.5, width/5-5, width/5-5)];
                    [imageIs sd_setImageWithURL:[NSURL URLWithString:detailMessage.img_pathsAry[i]]];
                    //给图片添加点击事件
                    imageIs.tag=i+1000;
                    imageIs.userInteractionEnabled=YES;
                    UITapGestureRecognizer*tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Actiondo:)];
                    
                    [imageIs addGestureRecognizer:tapGesture];
                    [cell addSubview:imageIs];
                }
            }
            
            
            [cell addSubview:messageL];
        }
        return cell;
    }
    if (baojiaArray.count==0) {
        UITableViewCell*cell=[[UITableViewCell alloc]init];
        cell.backgroundColor=[UIColor groupTableViewBackgroundColor];
        UILabel*cellLabel=[[UILabel alloc]init];
        cellLabel.font=font14;
        cellLabel.numberOfLines=0;
        cellLabel.textColor=Color153;
        cellLabel.frame=CGRectMake(18, 0, width-18, 80);
        [cell addSubview:cellLabel];
        switch (detailMessage.status) {
            case 0://待审核
            {
                cellLabel.text=@"您的询单正在审核(首单审核),请耐心等待！\n给您带来不变请见谅。\n如有问题可以拨打我们的客服热线,点击页面左下角的呼叫客服。";
            }
                break;
            case -1://无效
            {
                cellLabel.text=@"您的询单填写有误,目前已被作废。\n您可点击编辑询单按钮,修改询单重新发布。\n或者呼叫客户协助完成求购。";
            }
                break;
            case 10://报价中但是没有人报价
            {
                cellLabel.text=@"暂无商家报价,请等待！\n您可拨打我们的客服热线,帮您完成选货。";
            }
                break;
            default:
                break;
        }
        return cell;
        
    }
    else{
        Quoteinfons*quoteinfons=baojiaArray[indexPath.row];
        isBlack=quoteinfons.is_add_black;
        if (detailMessage.status==10||detailMessage.status==20)
        {
            btnCell.selectionStyle=UITableViewCellSelectionStyleNone;
            //当前是哪一行
            sectionTrow=indexPath.row;
            btnCell=[tableView dequeueReusableCellWithIdentifier:@"btnCell"];
            if (quoteinfons.is_push==1) {
                btnCell.tui_jian.image=[UIImage imageNamed:@"ic_recommend_company"];
            }
            
            [btnCell.headImage sd_setImageWithURL:[NSURL URLWithString:quoteinfons.logo_imgPath] placeholderImage:[UIImage imageNamed:@"default_head_17"]];
            //显示星星
            CWStarRateView*stars=[[CWStarRateView alloc]initWithFrame:CGRectMake(0,0, 46,18) numberOfStars:5];
            
            stars.scorePercent=[quoteinfons.score floatValue]/5;
            stars.allowIncompleteStar = YES;
            [btnCell.start addSubview:stars];
            //显示分数
            UILabel*labelScore=[[UILabel alloc]initWithFrame:CGRectMake(46, 0, 28, 18)];
            labelScore.font=[UIFont systemFontOfSize:8];
            labelScore.textColor=[UIColor orangeColor];
            labelScore.text=[NSString stringWithFormat:@"%@分",quoteinfons.score];
            labelScore.textAlignment=NSTextAlignmentCenter;
            [btnCell.start addSubview:labelScore];
            
            if (quoteinfons.is_add_black==0){
                [btnCell.btnBN setTitle:@"+黑名单" forState:UIControlStateNormal];
            }
            else{
                [btnCell.btnBN setTitle:@"已黑" forState:UIControlStateNormal];
            }
            //点击将此人添加到黑名单
            [btnCell.btnBN addTarget:self action:@selector(addBlackName:) forControlEvents:UIControlEventTouchUpInside];
            btnCell.btnBN.tag=indexPath.row;
            btnCell.name.text=quoteinfons.user_name;
            
            if ([quoteinfons.price_unit integerValue]==10) {
                btnCell.baojiaMesage.text=[NSString stringWithFormat:@"%@元/吨",quoteinfons.quote_price];
            }
            if ([quoteinfons.price_unit integerValue]==20) {
                btnCell.baojiaMesage.text=[NSString stringWithFormat:@"%@元/张",quoteinfons.quote_price];
            }
            if([quoteinfons.price_unit integerValue]==30){
                btnCell.baojiaMesage.text=[NSString stringWithFormat:@"%@元/千克",quoteinfons.quote_price];
            }
            if ([quoteinfons.price_unit integerValue]==40) {
                btnCell.baojiaMesage.text=[NSString stringWithFormat:@"%@元/件",quoteinfons.quote_price];
            }
            
            [btnCell.phoneNum setTitle:quoteinfons.mobile forState:UIControlStateNormal];
            [btnCell.phoneNum addTarget:self action:@selector(callMaiJia:) forControlEvents:UIControlEventTouchUpInside];
            btnCell.phoneNum.tag=indexPath.row;
            btnCell.textMsg.text=quoteinfons.remark;
            
            //新加附位置
//            btnCell.bgImage.frame=CGRectMake(100, 15, 1, cellH-30);
//            btnCell.textMsg.frame=CGRectMake(162, btnCell.jiao_yi.bottom+5, beizhuW, beizhuH);
           
            cellH=[self stringRect:quoteinfons.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+135;
            beizhuW=self.view.frame.size.width-110-50-5-5;
            btnCell.bgImage.frame=CGRectMake(100, 15, 1, cellH-30);
            beizhuH=[self stringRect:quoteinfons.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]];
            btnCell.textMsg.frame=CGRectMake(162, 58, beizhuW, beizhuH+20);
           
            
            btnCell.oView.frame=CGRectMake(110, cellH-5-40, self.view.frame.size.width-110, 40);
            btnCell.tView.frame=CGRectMake(110, cellH-5-40, self.view.frame.size.width-110, 40);
            btnCell.thView.frame=CGRectMake(110, cellH-5-40, self.view.frame.size.width-110, 40);
            btnCell.fView.frame=CGRectMake(110, cellH-5-40, self.view.frame.size.width-110, 40);
            
            
            UIView *im=[[UIView  alloc]init];
            im.backgroundColor=[UIColor grayColor];
            im.frame=CGRectMake(5, cellH-1, btnCell.width, 1);
            im.hidden=NO;
            [btnCell addSubview:im];
            
            
            
            
            if (quoteinfons.status==-1)//取消状态
            {
                btnCell.oView.hidden=YES;
                btnCell.tView.hidden=YES;
                btnCell.thView.hidden=YES;
                btnCell.fView.hidden=NO;
            }
            if (quoteinfons.status==0)//未锁货
            {
                btnCell.oView.hidden=NO;
                btnCell.tView.hidden=YES;
                btnCell.thView.hidden=YES;
                btnCell.fView.hidden=YES;
                //点击锁货按钮
                [btnCell.suoHuo1 addTarget:self action:@selector(suoHuo:) forControlEvents:UIControlEventTouchUpInside];
                btnCell.suoHuo1.tag=indexPath.row;
                [btnCell.xiaDan1 addTarget:self action:@selector(xia_Dan:) forControlEvents:UIControlEventTouchUpInside];
                btnCell.xiaDan1.tag=indexPath.row+100;
            }
            if (quoteinfons.status==10)//出局
            {
                btnCell.oView.hidden=YES;
                btnCell.tView.hidden=YES;
                btnCell.thView.hidden=YES;
                btnCell.fView.hidden=NO;
            }
            if (quoteinfons.status==20)//已锁货
            {
                btnCell.oView.hidden=YES;
                btnCell.thView.hidden=YES;
                btnCell.fView.hidden=YES;
                btnCell.tView.hidden=NO;
                //确认下单
                btnCell.sure2.tag=indexPath.row+100;
                [btnCell.sure2 addTarget:self action:@selector(xia_Dan:) forControlEvents:UIControlEventTouchUpInside];
                //放弃锁货
                btnCell.giveUp2.tag=indexPath.row;
                [btnCell.giveUp2 addTarget:self action:@selector(giveUp:) forControlEvents:UIControlEventTouchUpInside];
            }
            
            if (quoteinfons.status==30)//已成交
            {
                btnCell.oView.hidden=YES;
                btnCell.tView.hidden=YES;
                btnCell.thView.hidden=NO;
                btnCell.fView.hidden=YES;
                btnCell.check3.tag=indexPath.row;
                [btnCell.check3 addTarget:self action:@selector(check:) forControlEvents:UIControlEventTouchUpInside];
            }
            return btnCell;
        }
        
        else{
            cell2=[tableView dequeueReusableCellWithIdentifier:@"textCell"];
            cell2.selectionStyle=UITableViewCellSelectionStyleNone;
            
            UILabel*cellLabel=[[UILabel alloc]init];
            cellLabel.font=font14;
            cellLabel.numberOfLines=0;
            cellLabel.frame=CGRectMake(0, 0, width, cell2.frame.size.height);
            [cell2 addSubview:cellLabel];
            
            //当前是哪一行
            sectionTrow=indexPath.row;
            if (quoteinfons.is_push==1) {
                cell2.tui_jian.image=[UIImage imageNamed:@"ic_recommend_company"];
            }
            [cell2.headImage sd_setImageWithURL:[NSURL URLWithString:quoteinfons.logo_imgPath] placeholderImage:[UIImage imageNamed:@"default_head_17"]];
            //显示星星
            CWStarRateView*stars=[[CWStarRateView alloc]initWithFrame:CGRectMake(0,0, 46,18) numberOfStars:5];
            stars.scorePercent=[quoteinfons.score floatValue]/5;
            stars.allowIncompleteStar = YES;
            [cell2.start addSubview:stars];
            //显示分数
            UILabel*labelScore=[[UILabel alloc]initWithFrame:CGRectMake(46, 0, 28, 18)];
            labelScore.font=[UIFont systemFontOfSize:8];
            labelScore.textColor=[UIColor orangeColor];
            labelScore.text=[NSString stringWithFormat:@"%@分",quoteinfons.score];
            labelScore.textAlignment=NSTextAlignmentCenter;
            [cell2.start addSubview:labelScore];
            
            
            if (quoteinfons.is_add_black==0){
                [cell2.btnBN setTitle:@"+黑名单" forState:UIControlStateNormal];
            }
            else{
                [cell2.btnBN setTitle:@"已黑" forState:UIControlStateNormal];
            }
            [cell2.btnBN addTarget:self action:@selector(addBlackName:) forControlEvents:UIControlEventTouchUpInside];
            cell2.btnBN.tag=indexPath.row;
            cell2.name.text=quoteinfons.user_name;
            
            if ([quoteinfons.price_unit integerValue]==10) {
                cell2.baojiaMesage.text=[NSString stringWithFormat:@"%@元/吨",quoteinfons.quote_price];
            }
            if ([quoteinfons.price_unit integerValue]==20) {
                cell2.baojiaMesage.text=[NSString stringWithFormat:@"%@元/张",quoteinfons.quote_price];
            }
            if([quoteinfons.price_unit integerValue]==30){
                cell2.baojiaMesage.text=[NSString stringWithFormat:@"%@元/千克",quoteinfons.quote_price];        }
            if ([quoteinfons.price_unit integerValue]==40) {
                cell2.baojiaMesage.text=[NSString stringWithFormat:@"%@元/件",quoteinfons.quote_price];
            }

            
//            cell2.baojiaMesage.text=[NSString stringWithFormat:@"%@元/吨",quoteinfons.quote_price];
            [cell2.phoneNum setTitle:quoteinfons.mobile forState:UIControlStateNormal];
            [cell2.phoneNum addTarget:self action:@selector(callMaiJia:) forControlEvents:UIControlEventTouchUpInside];
            cell2.phoneNum.tag=indexPath.row;
            cell2.textMsg.text=quoteinfons.remark;
            
            //新加附位置
            
            cellH=[self stringRect:quoteinfons.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+80;
            beizhuW=self.view.frame.size.width-110-50-5-5;
            cell2.bgImage.frame=CGRectMake(100, 15, 1, cellH-30);
            beizhuH=[self stringRect:quoteinfons.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]];
            cell2.textMsg.frame=CGRectMake(162, 65, beizhuW, beizhuH);
            
            UIView *im=[[UIView  alloc]init];
            im.backgroundColor=[UIColor grayColor];
            im.frame=CGRectMake(5, cell2.textMsg.bottom+14, cell2.width, 1);
            im.hidden=YES;
            [cell2 addSubview:im];
            
            if (baojiaArray.count>=2) {
                im.hidden=NO;
            }
            
            
            
            return cell2;
        }
    }
}

//返回区头的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return 25;
    }
    return 55;
}
//返回每个单元格的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section==0){
        if (indexPath.row==6) {
            NSString*manufacturer=detailMessage.manufacturer_name;
            if (manufacturer.length==0) {
                manufacturer=@"无";
            }
            NSString*shengCityManufacturer=[NSString stringWithFormat:@"%@%@/%@",[ProvinceAndCity inputShengID:detailMessage.supply_provinceID],[ProvinceAndCity inputCityID: detailMessage.supply_cityID],manufacturer];//省市、生产商
            return [self stringRect:shengCityManufacturer uiWidth:125 font:[UIFont systemFontOfSize:15]]+18;
        }
        if (indexPath.row==8)
        {
            return [self stringRect:detailMessage.remark uiWidth:125 font:[UIFont systemFontOfSize:15]]+18;
        }
        if (indexPath.row==9) {
            if (detailMessage.img_pathsAry.count==0) {
                return 1;
            }
            else{
                return width/5;
            }
        }
        return 33;
    }
    
    //先算出备注的宽
    beizhuW=self.view.frame.size.width-110-50-5-5;
    if (detailMessage.status==10||detailMessage.status==20){
        if (baojiaArray.count==0) {
            beizhuH=15;
            cellH=60;
            return 60;
        }else{
            Quoteinfons*quote=baojiaArray[indexPath.row];
            cellH=[self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+135;
            beizhuH=[self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]];
            return [self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+135;
        }
    }else{
        
        if (baojiaArray.count==0) {
            beizhuH=15;
            cellH=60;
            return 60;
        }else{
            Quoteinfons*quote=baojiaArray[indexPath.row];
            cellH=[self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+80;
            beizhuH=[self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]];
            return [self stringRect:quote.remark uiWidth:beizhuW font:[UIFont systemFontOfSize:15]]+80;
        }
    }
}

//返回区头view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UITableViewHeaderFooterView*headerView=[[UITableViewHeaderFooterView alloc]init];
    if (section==0)
    {
        //显示状态的图片
        ststusImage=[[UIImageView alloc]init];
        [headerView addSubview:ststusImage];
        [ststusImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(2.5);
            make.left.offset(6);
            make.height.offset(20);
            make.width.offset(20);
        }];
        statusLabel=[[UILabel alloc]init];
        statusLabel.font=[UIFont systemFontOfSize:15];
        [headerView addSubview:statusLabel];
        [statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(ststusImage.mas_right).offset(1);
            make.top.offset(2.5);
            make.height.offset(20);
            make.width.offset(150);
        }];
        
        [headerView addSubview:backDjs];
        
        if (detailMessage.status==-2 ){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_timeup"];
            statusLabel.text=@"已过期";
            titleLabel.text=@"已过期";
            backDjs.hidden=YES;
        }
        
        if (detailMessage.status==-1){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_timeup"];
            statusLabel.text=@"无效";
            titleLabel.text=@"无效";
            backDjs.hidden=YES;
        }
        
        if (detailMessage.status==0){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_quotation"];
            statusLabel.text=@"待审核";
            titleLabel.text=@"待审核";
            backDjs.hidden=YES;
        }
        
        if (detailMessage.status==10){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_quotation"];
            statusLabel.text=@"报价中";
            titleLabel.text=@"报价中";
            backDjs.hidden=NO;
        }
        
        if (detailMessage.status==15){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_cancel"];
            statusLabel.text=@"已关闭";
            titleLabel.text=@"已关闭";
            backDjs.hidden=YES;
        }
        
        if (detailMessage.status==20){
            ststusImage.image=[UIImage imageNamed:@"ic_qiugou_waiting"];
            statusLabel.text=@"待处理";
            titleLabel.text=@"待处理";
            backDjs.hidden=YES;
        }
        return headerView;
    }
    UIImageView*xuanHuoImg=[[UIImageView alloc]init];
    xuanHuoImg.image=[UIImage imageNamed:@"Free_to_find_goods"];
    [headerView addSubview:xuanHuoImg];
    [xuanHuoImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(6);  make.top.offset(4);  make.height.offset(22);   make.width.offset(22);
    }];
    
    UILabel*xuanHuoL=[[UILabel alloc]init];
    xuanHuoL.text=@"免费选货";
    xuanHuoL.font=font14;
    [headerView addSubview:xuanHuoL];
    [xuanHuoL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(33);   make.top.offset(4);  make.height.offset(22);  make.width.offset(200);
    }];
    
    
    
    UILabel*texLabel=[[UILabel alloc]init];
    texLabel.text=[NSString stringWithFormat:@"推送%@家,%@条报价,最低价:%@",detailMessage.send_conut,detailMessage.quote_num,detailMessage.min_price];
    texLabel.backgroundColor=[UIColor groupTableViewBackgroundColor];
    texLabel.font=[UIFont systemFontOfSize:15];
    [headerView addSubview:texLabel];
    [texLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(6);
        make.height.offset(20);
        make.top.offset(32.5);
        make.width.offset(width);
    }];
    return headerView;
}

#pragma mark----------------各种按钮的点击时间
//给卖家拨打电话
-(void)callMaiJia:(UIButton*)buton
{
    Quoteinfons*quotePhone=baojiaArray[buton.tag];
    //进入打电话页面
    UIWebView *webview = [[UIWebView alloc] init];
    NSString*phongStr=[NSString stringWithFormat:@"tel:%@",quotePhone.mobile];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:phongStr]]];
    [self.view addSubview:webview];
}
//返回上一级
-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}
//点击添加黑名单
-(void)addBlackName:(UIButton*)button
{
    [MobClick event:@"addToBlacklist"];
    
    self.addBlackBtnTag=button.tag;
    Quoteinfons*quote=baojiaArray[button.tag];
    addBcompanyID=quote.companyID;
    if (quote.is_add_black==1) {
        return;
    }
    
    UIAlertView*alertView=[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"你确定要将该公司加入黑名单,加入黑名单你将不再收到该公司的推送" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
    alertView.tag=500;
    [alertView show];
}

//点击锁货执行的方法
-(void)suoHuo:(UIButton*)btn
{
//    NSString*purchaseID=[NSString stringWithFormat:@"%ld",(long)detailMessage.purchaseID ];
    
    [MobClick event:@"lockGoods"];
    
    NSString*purchaseID=self.purchaseID;
    
    Quoteinfons*quote=baojiaArray[btn.tag];
    NSString*quoteID=quote.quoteID;
    
    //NSDictionary*dic=@{@"purchase_id":purchaseID,@"quote_id":quoteID};
    NSDictionary*dic=@{@"PURCHASE_ID":purchaseID,@"QUOTE_ID":quoteID,@"USER_ID":quote.userID,@"COMPANY_ID":quote.companyID};
    [Controller requestWithURL:@"AppQuoteInfo/PostLockQuote?from=app" jsondic:dic finishBlock:^(ClassData *classData) {
        NSInteger code=[classData.number integerValue];
        if (code==0) {
            [quote setValue:@"20" forKey:@"status"];
            [_tableView reloadData];
        }
        else{
            ALERTSHOW(classData.message);
        }
    }];
    
}

//放弃锁货
-(void)giveUp:(UIButton*)btn
{
    [MobClick event:@"qiugou_giveUp"];
    
//    NSString*qiuGouID=[NSString stringWithFormat:@"%ld",(long)detailMessage.purchaseID ];//求购ID
    NSString*qiuGouID=self.purchaseID;
    Quoteinfons*quote=baojiaArray[btn.tag];
    NSString*baoJiaID=quote.quoteID;//报价ID
    NSString*maiJiaID=quote.userID;//卖家ID
    NSString*gongSiID=quote.companyID;//公司ID
    NSDictionary*dic=@{@"PURCHASE_ID":qiuGouID,@"QUOTE_ID":baoJiaID,@"USER_ID":maiJiaID,@"COMPANY_ID":gongSiID};
    [Controller requestWithURL:@"AppQuoteInfo/PostCancelRecord?from=app" jsondic:dic finishBlock:^(ClassData *classData) {
        NSInteger code=[classData.number integerValue];
        if (code==0){
            [quote setValue:@"10" forKey:@"status"];
            [_tableView reloadData];
        }
        else{
            ALERTSHOW(classData.message);
        }
    }];
    
}

//拨打客服电话
-(void)callPhone
{
    //进入打电话页面
    UIWebView *webview = [[UIWebView alloc] init];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:4008850051"]]];
    [self.view addSubview:webview];
    //[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://4008850051"]];
}

//点击取消按钮取消求购
-(void)quxiao_Btn
{
    
    UIAlertView*alertView=[[UIAlertView alloc]initWithTitle:@"提示" message:@"没有找到合适的货吗? \n 你可已拨打我们的客服热线，帮你完成选货 " delegate:self cancelButtonTitle:@"呼叫客服" otherButtonTitles:@"取消求购",nil];
    alertView.tag=1000;
    [alertView show];
    
}

//重新采购按钮
-(void)again_Btn
{
    AccurateVC*accurate=[[AccurateVC alloc]init];
    accurate.detailes=detailMessage;
    
    accurate.typeString=detailMessage.category_name;//传过去字符串（判断该以什么样的方式显示）
    accurate.pageString=@"求购重新采购";
    [self.navigationController pushViewController:accurate animated:YES];
}

//下单按钮
-(void)xia_Dan:(UIButton*)btn
{
    
    if ([btn.titleLabel.text isEqualToString:@"确认订单"]) {
        
        [MobClick event:@"qiugou_ConfirmOrder"];
        
    }else{
        [MobClick event:@"qiugou_DirectOrder"];
    
    }
    
    
    Quoteinfons*quoteinfons=baojiaArray[btn.tag-100];
    NSString*price=quoteinfons.quote_price;
    NSString*unit=quoteinfons.price_unit;
    [XiaDan showPickerView:self.view withTitle:@"   确认交易:" classType:detailMessage.category_name leiMing:detailMessage.variety_name oderID:price unit:unit andSelectBlock:^(NSString *Sstr) {
        NSArray*ary=[Sstr componentsSeparatedByString:@"|"];
        NSString*CONFIRM_QUANTITY=ary[0];
        NSString*IS_NEED_TESTING=ary[1];
        NSString*xiaDanUnit=ary[2];
//        NSString*purchaseId=[NSString stringWithFormat:@"%ld",(long)detailMessage.purchaseID];
        NSString*purchaseId=self.purchaseID;
        
        NSString*quoteId=quoteinfons.quoteID;
        //@"CONFIRM_UNIT" ;  @"CONFIRM_QUANTITY";
    NSDictionary*dic=@{@"PURCHASE_ID":purchaseId,@"QUOTE_ID":quoteId,@"IS_NEED_TESTING":IS_NEED_TESTING,@"CONFIRM_QUANTITY":CONFIRM_QUANTITY,@"CONFIRM_UNIT":xiaDanUnit};
        
        [Controller requestWithURL:@"AppQuoteInfo/PostConfirmRecord?from=app" jsondic:dic finishBlock:^(ClassData *data) {
            
            NSDictionary*dict=[[NSDictionary alloc]init];
            dict=data.data;
            if ([data.number integerValue]==0) {
                [quoteinfons setValue:@"30" forKey:@"status"];
                if ([[dict allKeys]containsObject:@"ORDER_ID"]) {
                    [quoteinfons setValue:dict[@"ORDER_ID"] forKey:@"orderID"];
                    [_tableView reloadData];
                }
                else{
                    ALERTSHOW(data.message);
                }
            }
        }];
    }];
    
}

//点击进入订单详情页面
-(void)check:(UIButton*)btn
{
    Quoteinfons*quone=baojiaArray[btn.tag];
    OrderDetailesVC*orderDVC=[[OrderDetailesVC alloc]init];
    orderDVC.orderID=quone.orderID;
    [self.navigationController pushViewController:orderDVC animated:YES];
}

#pragma mark------警告框的协议方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag==500)
    {
        if (buttonIndex==1) {
            Quoteinfons*quote=baojiaArray[self.addBlackBtnTag];
            addBcompanyID=quote.companyID;
            NSDictionary*dic=@{@"SELLER_COMPANY_ID":addBcompanyID};
            [Controller requestWithURL:@"AppCompanyRegist/PostAddBlackList?from=app" jsondic:dic finishBlock:^(ClassData *classData) {
                
                NSInteger code=[classData.number integerValue];
                if (code==0)
                {
                    for (Quoteinfons*quoteInfo in baojiaArray) {
                        if ([quoteInfo.companyID integerValue]==[quote.companyID integerValue]) {
                            [quoteInfo setValue:@"1" forKey:@"is_add_black"];
                        }
                    }
                    [_tableView reloadData];
                    
                    UIAlertView*alertV=[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"加入黑名单成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
                    [alertV show];
                    
                }
                else{
                    ALERTSHOW(classData.message);
                }
            }];
            
        }
    }
    if (alertView.tag==1000) {
        if (buttonIndex==0) {
            //进入打电话页面
            UIWebView *webview = [[UIWebView alloc] init];
            [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:4008850051"]]];
            [self.view addSubview:webview];
        }
        if (buttonIndex==1) {
//            NSString*str=[NSString stringWithFormat:@"%ld",(long)detailMessage.purchaseID];
            // __weak DetailesClass*det=detailMessage;
            [CancelReason showPickerView:self.view withTitle:@"      取消原因:" oderID:self.purchaseID andSelectBlock:^(NSString *string) {
                if ([string isEqualToString:@"成功"]) {
                    dispatch_source_cancel(self.djs.timer);
                    [detailMessage setValue:@"15" forKey:@"status"];
                    [self viewDidLoad];
                    [_tableView reloadData];
                };
            }];
            
        }
    }
    
}

#pragma mark--------------其他方法
//计算文字高度
-(NSInteger)stringRect:(NSString*)str uiWidth:(NSInteger)widt font:(UIFont*)lfont
{
    //CGRect rect=[str boundingRectWithSize:CGSizeMake(widt, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:lfont ,NSFontAttributeName, nil] context:nil].size.height;
    //MAXFLOAT
    CGRect rect = [str boundingRectWithSize:CGSizeMake(widt, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:[[NSDictionary alloc] initWithObjectsAndKeys:lfont,NSFontAttributeName, nil] context:nil];
    return rect.size.height;
}


#pragma mark---------------------收到通知消息时要执行的方法

-(void)upview:(NSNotification*)notification
{
    NSDictionary *dic = [notification object];//获取到传递的对象
    pushDatamodel *pushmodel=[[pushDatamodel alloc]initWith:dic];
    
    if (detailMessage.status==10) {
        
        NSInteger purchaseId=[pushmodel.data[@"purchaseID"]integerValue];
        
        if (detailMessage.purchaseID==purchaseId) {
            
            //求购已取消
            if (pushmodel.type==3){
                //ALERTSHOW(@"求购已取消");
                [detailMessage setValue:@"-1" forKey:@"status"];
                [_tableView reloadData];
            }
            
            //求购有新报价
            if (pushmodel.type==4) {
                //ALERTSHOW(@"求购有新报价");
                NSArray*arry=pushmodel.data[@"add"];
                for (NSDictionary*dic in arry) {
                    Quoteinfons*quote=[[Quoteinfons alloc]initWithDic:dic];
                    [baojiaArray addObject:quote];
                }
                [_tableView reloadData];
            }
            
            //求购报价已修改
            if (pushmodel.type==5) {
                //ALERTSHOW(@"求购报价已修改");
                for (Quoteinfons*quote in baojiaArray) {
                    if (quote.quoteID==pushmodel.data[@"quote"][@"QUOTE_ID"]) {
                        //修改最后操作时间
                        [quote setValue:pushmodel.data[@"quote"][@"LAST_OPERATOR_TIME"]forKey:@"last_operator_time"];
                        //修改报价价格
                        [quote setValue:pushmodel.data[@"quote"][@"QUOTE_PRICE"] forKey:@"quote_price"];
                        //修改报价单位
                        [quote setValue:pushmodel.data[@"quote"][@"PRICE_UNIT"] forKey:@"price_unit"];
                        //修改当前报价状态
                        [quote setValue:pushmodel.data[@"quote"][@"STATUS"] forKey:@"status"];
                        //修改备注
                        [quote setValue:pushmodel.data[@"quote"][@"REMARK"] forKey:@"remark"];
                        //如果直接下单了需要存储一下下单的ID
                        if ([[pushmodel.data[@"quote"] allKeys] containsObject:@"ORDER_ID"]) {
                            [quote setValue:pushmodel.data[@"quote"][@"ORDER_ID"]  forKey:@"orderID"];
                        }
                        [_tableView reloadData];
                    }
                    
                }
            }
            
            //求购报价已取消
            if (pushmodel.type==6) {
                //            ALERTSHOW(@"求购报价已取消");
                NSInteger  baojiaID=[pushmodel.data[@"quoteID"] integerValue];
                for (Quoteinfons*quote in baojiaArray) {
                    if (quote.quoteID.integerValue==baojiaID) {
                        [quote setValue:@"-1" forKey:@"status"];
                        //[baojiaArray removeObject:quote];
                    }
                }
                [_tableView reloadData];
            }
            
            //求购已确认报价（锁货)
            if (pushmodel.type==7) {
                //ALERTSHOW(@"求购已确认报价（锁货)");
                NSInteger quoteId=[pushmodel.data[@"quote"][@"QUOTE_ID"]integerValue];
                for (Quoteinfons*quote in baojiaArray) {
                    if (quote.quoteID.integerValue==quoteId) {
                        [quote setValue:@"20" forKey:@"status"];
                        [_tableView reloadData];
                    }
                }
            }
            
            //锁货后放弃
            if (pushmodel.type==8) {
                //ALERTSHOW(@"锁货后放弃");
                NSInteger quoteId=[pushmodel.data[@"quoteID"]integerValue];
                for (Quoteinfons*quote in baojiaArray) {
                    if (quote.quoteID.integerValue==quoteId) {
                        [quote setValue:@"10" forKey:@"status"];
                        [_tableView reloadData];
                    }
                }
            }
            
            //求购已成交
            if (pushmodel.type==9) {
                //ALERTSHOW(@"求购已成交");
                NSInteger quoteId=[pushmodel.data[@"quoteID"]integerValue];
                NSString*orderID=pushmodel.data[@"orderID"];
                for (Quoteinfons*quote in baojiaArray) {
                    if (quote.quoteID.integerValue==quoteId) {
                        [quote setValue:@"30" forKey:@"status"];
                        [quote setValue:orderID forKey:@"orderID"];
                        [_tableView reloadData];
                    }
                }
            }
            
            
        }
        
    }
    else{
        return;
    }
    
}
-(void)Actiondo:(UITapGestureRecognizer *)recognizer
{
    
    
    UIImageView *tekuba_net=[recognizer view];
    
    [BigimageView showImage:tekuba_net];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */


@end